<template>
  <h1>El-表单组件</h1>
  <h2>注册页面</h2>
  <el-form label-width="80" style="width: 500px;margin: 0 auto;">
    <el-form-item label="用户名">
      <el-input v-model="user.username" placeholder="请输入用户名"></el-input>
    </el-form-item>
    <el-form-item label="密码">
      <el-input v-model="user.password" show-password placeholder="请输入密码"></el-input>
    </el-form-item>
    <el-form-item label="性别">
      <el-radio-group v-model="user.gender">
        <!--label单选上显示的文字,如果没有设置选项提交的值value，label则作为value使用-->
        <el-radio-button label="男" value="1"></el-radio-button>
        <el-radio-button label="女" value="0"></el-radio-button>
      </el-radio-group>
    </el-form-item>
    <el-form-item label="所在地">
      <el-select placeholder="请选择你的城市:" v-model="user.city">
        <!--value选项要提交的值
        label选项的标签文字，若不设置则默认与value相同-->
        <el-option label="北京" value="bj"></el-option>
        <el-option label="上海" value="sh"></el-option>
        <el-option label="广州" value="gz"></el-option>
        <el-option label="深圳" value="sz"></el-option>
      </el-select>
    </el-form-item>
    <el-form-item label="管理员">
      <el-switch v-model="user.isAdmin"></el-switch>
    </el-form-item>
    <el-form-item>
      <el-button type="success" @click="show()">注册</el-button>
    </el-form-item>
  </el-form>
</template>

<script setup>
import {ref} from "vue";

const user = ref({username:'',password:'',gender:'男',city:'',isAdmin:true});
const show = ()=>{
  console.log(user.value);
}
</script>

<style scoped>

</style>